package cn.biplam.back.bean.ddl.sql2db.index;

import java.util.Iterator;
import java.util.Map.Entry;

import cn.biplam.back.sql.ddl.Index;
import cn.biplam.back.sql.ddl.Table;
import cn.biplam.common.wrapper.KvMap;

public class IndexCommen {
	
	public String get(Table table){
		KvMap<String, Index> indexs = table.getIndexs();
		if(indexs.size()<1){
			return null;
		}
		/**列字段迭代器*/
		Iterator<Entry<String, Index>> ite ;

		/**初始化*/
		ite= indexs.getIterator();
		StringBuilder sb = new StringBuilder();

		Index mIndex = null;
		while(ite.hasNext()){
			mIndex = ite.next().getValue();
			sb.append(" create index "+mIndex.getIndexName()+" on TEST (");
			for(String str:mIndex.getAIndexColumns()){
				sb.append(" "+str);
				sb.append(" ,");
			}
			sb.append(" )\n");
		}
		sb.append(" \n");
		return sb.toString();
	}
}
